package eu.jpereira.trainings.designpatterns.creational.builder;

import java.util.Iterator;

import eu.jpereira.trainings.designpatterns.creational.builder.model.ReportBody;
import eu.jpereira.trainings.designpatterns.creational.builder.model.ReportBodyBuilder;
import eu.jpereira.trainings.designpatterns.creational.builder.model.SoldItem;

public class HTMLReportBodyBuilder implements ReportBodyBuilder
{
	HTMLReportBody reportBody;
	boolean itemsAdded;
	
	public HTMLReportBodyBuilder()
	{
		reportBody = new HTMLReportBody();
		itemsAdded = false;
	}
	@Override
	public ReportBodyBuilder setCustomerName(String customerName)
	{
		reportBody.putContent("<span class=\"customerName\">" + customerName + "</span>");
		return null;
	}

	@Override
	public ReportBodyBuilder setCustomerPhone(String phoneNumber)
	{
		reportBody.putContent("<span class=\"customerPhone\">" + phoneNumber + "</span>");
		return null;
	}

	@Override
	public ReportBodyBuilder withItems()
	{
		if(!itemsAdded) reportBody.putContent("<items>");
		else reportBody.putContent("</items>");
		return null;
	}

	@Override
	public ReportBodyBuilder newItem(String name, int quantity, double price)
	{
		reportBody.putContent("<item><name>" + name + "</name><quantity>" + quantity + "</quantity><price>" + price + "</price></item>");
		return null;
	}

	@Override
	public ReportBody getReportBody()
	{
		// TODO Auto-generated method stub
		return reportBody;
	}
	@Override
	public void setItemsAdded(boolean b)
	{
		itemsAdded = b;
	}

}
